/**
* 版权声明：睿商(厦门)科技股份有限公司 版权所有 违者必究
* 日    期：2021-07-06
*/
package com.rzico.admin.service;

import com.rzico.admin.model.ProjectStatistics;
import com.rzico.base.BaseMapper;
import com.rzico.base.impl.BaseServiceImpl;
import com.rzico.admin.entity.Project;
import com.rzico.exception.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rzico.admin.mapper.ProjectMapper;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <pre>
 * 项目活动记录表业务类
 * </pre>
 *
 * @author Rzico Boot
 * @version 1.0
 */
@Service
public class ProjectService extends BaseServiceImpl<Project, String> {

    @Autowired
    private ProjectMapper projectMapper;

    @Override
    public BaseMapper<Project, String> getMapper() {
        return projectMapper;
    }

    public ProjectStatistics selectProjectStatistics(Map<String, Object> params){
        return projectMapper.selectProjectStatistics(params);
    }

    //审核
    public int adopt(Long workOrderId){
        Project project=projectMapper.selectByPrimaryKey(workOrderId);
        project.setModifyDate(new Date());
        project.setStatus(2);

        int result=projectMapper.updateByPrimaryKeySelective(project);
        return result;
    }
    //驳回
    public int reject(Long workOrderId,String rejectText){
        Project project=projectMapper.selectByPrimaryKey(workOrderId);
        project.setModifyDate(new Date());
        project.setStatus(3);
        project.setMemo(rejectText);

        int result=projectMapper.updateByPrimaryKeySelective(project);
        return result;
    }

    //提交
    public int submit(Long workOrderId){
        Project project=projectMapper.selectByPrimaryKey(workOrderId);
        project.setModifyDate(new Date());
        project.setStatus(1);

        int result=projectMapper.updateByPrimaryKeySelective(project);
        return result;
    }
}
